package com.wn.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @FileName: MyHttpChannelInitializer
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2020/7/29 - 16:50
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
public class MyHttpChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline()
                .addLast("myHttpServerCodec", new HttpServerCodec())
                .addLast("myHttpChannelHandler", simpleHandlerFactory());
    }

    private SimpleChannelInboundHandler<HttpObject> simpleHandlerFactory() {
        return new MyHttpChannelHandler();
    }
}
